package com.gzsxy.esjy.thread;


import com.gzsxy.esjy.NettyDispatcher;
import com.gzsxy.esjy.mapping.MappingEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;

import java.util.Map;


/**
 * 执行服务
 * @author zhangxiaolong
 * @date 2022/7/6 9:36
 */
public class ExcuteService {

	@Autowired
	private NettyDispatcher nettyDispatcher ;
	
	/**
	 * 执行服务
	 * @param mapping
	 * @param path
	 * @param requestBody
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public Object excute(MappingEntity mapping, String path, String requestBody, Map<String, Object> params) throws Exception {
		String bodyName = mapping.getBodyName();
		if(StringUtils.hasText(bodyName)) {
			params.put(bodyName, requestBody) ;
		}
		return nettyDispatcher.service(mapping,path,params);
	}
	
}
